Skip to content

Fixes pathways integration#89

Draft
JyotinderSingh wants to merge 2 commits intomainfrom
pathways-fixes
Draft

Fixes pathways integration#89
JyotinderSingh wants to merge 2 commits intomainfrom
pathways-fixes

Conversation

@JyotinderSingh
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the integration of Pathways with distributed JAX workloads, particularly when utilizing multi-node TPU accelerators on Google Kubernetes Engine (GKE). The changes refine how TPU resources are requested and allocated, ensuring compatibility with Podslice architectures, and introduce robust verification steps within the example code to confirm proper distributed environment setup and collective communication. These updates aim to provide a more reliable and debuggable experience for users running large-scale JAX computations on Pathways.

Highlights

  • Enhanced Multi-Node TPU Support: Modified the GKE client to correctly calculate and request per-node TPU resources for multi-node Podslices, ensuring proper scheduling and allocation.
  • Improved Pathways Example with JAX Verification: Updated the pathways_example.py to use a v6e-16 accelerator and added comprehensive JAX distributed environment verification, including process/device counts and collective communication checks.
  • Standardized Resource Request Formatting: Ensured that resource limits and requests are consistently converted to string format before being sent to the Kubernetes API in both GKE and Pathways clients.
  • Refined Pending Job Logging: Introduced a mechanism to prevent redundant logging of pending job statuses in the Pathways client.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • examples/pathways_example.py
    • Updated the keras_remote.run decorator to specify accelerator="v6e-16" and cluster="keras-team-dogfood".
    • Added JAX imports (jax, jax.lax) and extensive code to verify the distributed JAX environment, including process/device counts and a collective communication check using jax.pmap and lax.psum.
  • keras_remote/backend/gke_client.py
    • Modified _parse_accelerator to calculate chips_per_node for TPU Podslices, ensuring resource_limits and resource_requests are set per node.
    • Updated _create_job_spec to explicitly convert resource limits and requests to string format using dictionary comprehensions.
    • Adjusted _check_node_pool_exists_cached to use chips // topo_spec.num_nodes when setting the gke-accelerator-count label for node pool matching.
  • keras_remote/backend/gke_client_test.py
    • Added test_tpu_v3_16_multi_node to verify correct parsing of multi-node TPU configurations.
    • Added test_tpu_multi_node_match to test the node pool matching logic for multi-node TPUs.
  • keras_remote/backend/pathways_client.py
    • Initialized logged_pending as a set in wait_for_job to track logged pending statuses.
    • Passed the logged_pending set to _check_pod_scheduling to manage pending status logging.
    • Updated _create_lws_spec to explicitly convert resource limits and requests to string format.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces fixes for Pathways integration, specifically for multi-node TPU configurations. The changes correctly calculate per-node resource requests for TPU podslices in gke_client.py and add corresponding tests. The Pathways example is updated to verify multi-host execution. My review focuses on the robustness of the new example code. I've identified a potential issue in the exception handling logic that could swallow errors and have suggested a fix.

Comment on lines +55 to +60
except Exception as e:
print(f"Warning: Collective verification failed: {e}")
if isinstance(e, RuntimeError) and "Collective verification failed" in str(
e
):
raise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current exception handling logic is risky because it swallows most exceptions. The except Exception block only re-raises a RuntimeError if it contains the specific string "Collective verification failed". Any other exception (including other RuntimeErrors or errors from JAX) will be caught, a warning printed, and then the exception will be swallowed, allowing the script to continue as if no error occurred. This can hide underlying problems and lead to silent failures.

It's safer to ensure that any failure during verification causes the job to fail. I recommend simplifying the exception handling to always re-raise after logging, like this:

  except Exception as e:
    print(f"Error: Collective verification failed: {e}")
    raise

Alternatively, you could remove the try...except block entirely if the goal is to just let any exception from the verification logic fail the job.

References
  1. The current exception handling is not robust as it can swallow critical errors, violating the principle of demanding robust code. The proposed change ensures failures are not silently ignored. (Rule 4: Demand Robustness) (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant